Impact of Macroeconomic Factors on Simon Property Group Inc Stock Price
One of the best companies in the real estate sector is Simon Property Group Inc. (SPG). Simon Property Group is a real estate investment trust (REIT) that owns and operates shopping malls, premium outlets, and mixed-use properties in the United States, Europe, and Asia. The company has a strong track record of generating steady rental income from its properties and has consistently paid out dividends to its shareholders. Additionally, Simon Property Group has a diversified portfolio of properties, which helps to mitigate risk and provide stable returns.
By using an ARIMAX+ARCH/GARCH model to analyze the stock price behavior ofSimon Property Group Inc., we can gain insights into how macroeconomic factors impact the company’s performance. For example, an increase in GDP growth rate or a decrease in unemployment rate may lead to increased consumer spending and a rise in Simon Property Group’s stock price. Conversely, an increase in inflation or interest rates may lead to a decrease in consumer spending and a decline in Simon Property Group’s stock price.
Time series Plot
Code
# get data
options("getSymbols.warning4.0"=FALSE)
options("getSymbols.yahoo.warning"=FALSE)
data.info = getSymbols("SPG",src='yahoo', from = '2010-01-01',to = "2023-03-01",auto.assign = FALSE)
data = getSymbols("SPG",src='yahoo', from = '2010-01-01',to = "2023-03-01")
df <- data.frame(Date=index(SPG),coredata(SPG))
# create Bollinger Bands
bbands <- BBands(SPG[,c("SPG.High","SPG.Low","SPG.Close")])
# join and subset data
df <- subset(cbind(df, data.frame(bbands[,1:3])), Date >= "2010-01-01")
# colors column for increasing and decreasing
for (i in 1:length(df[,1])) {
if (df$SPG.Close[i] >= df$SPG.Open[i]) {
df$direction[i] = 'Increasing'
} else {
df$direction[i] = 'Decreasing'
}
}
i <- list(line = list(color = '#C39BD3'))
d <- list(line = list(color = '#7F7F7F'))
# plot candlestick chart
fig <- df %>% plot_ly(x = ~Date, type="candlestick",
open = ~SPG.Open, close = ~SPG.Close,
high = ~SPG.High, low = ~SPG.Low, name = "SPG",
increasing = i, decreasing = d)
fig <- fig %>% add_lines(x = ~Date, y = ~up , name = "B Bands",
line = list(color = '#ccc', width = 0.5),
legendgroup = "Bollinger Bands",
hoverinfo = "none", inherit = F)
fig <- fig %>% add_lines(x = ~Date, y = ~dn, name = "B Bands",
line = list(color = '#ccc', width = 0.5),
legendgroup = "Bollinger Bands", inherit = F,
showlegend = FALSE, hoverinfo = "none")
fig <- fig %>% add_lines(x = ~Date, y = ~mavg, name = "Mv Avg",
line = list(color = '#C052B3', width = 0.5),
hoverinfo = "none", inherit = F)
fig <- fig %>% layout(yaxis = list(title = "Price"))
# plot volume bar chart
fig2 <- df
fig2 <- fig2 %>% plot_ly(x=~Date, y=~SPG.Volume, type='bar', name = "SPG Volume",
color = ~direction, colors = c('#C39BD3','#7F7F7F'))
fig2 <- fig2 %>% layout(yaxis = list(title = "Volume"))
# create rangeselector buttons
rs <- list(visible = TRUE, x = 0.5, y = -0.055,
xanchor = 'center', yref = 'paper',
font = list(size = 9),
buttons = list(
list(count=1,
label='RESET',
step='all'),
list(count=3,
label='3 YR',
step='year',
stepmode='backward'),
list(count=1,
label='1 YR',
step='year',
stepmode='backward'),
list(count=1,
label='1 MO',
step='month',
stepmode='backward')
))
# subplot with shared x axis
fig <- subplot(fig, fig2, heights = c(0.7,0.2), nrows=2,
shareX = TRUE, titleY = TRUE)
fig <- fig %>% layout(title = paste("Simon Property Group Inc Stock Price: January 2010 - March 2023"),
xaxis = list(rangeselector = rs),
legend = list(orientation = 'h', x = 0.5, y = 1,
xanchor = 'center', yref = 'paper',
font = list(size = 10),
bgcolor = 'transparent'))
figCode
log(data.info$`SPG.Adjusted`) %>% diff() %>% chartSeries(theme=chartTheme('white'),up.col='#C39BD3')Code
#import the data
gdp <- read.csv("DATA/RAW DATA/gdp-growth.csv")
#change date format
gdp$Date <- as.Date(gdp$DATE , "%m/%d/%Y")
#drop DATE column
gdp <- subset(gdp, select = -c(1))
#export the cleaned data
gdp_clean <- gdp
write.csv(gdp_clean, "DATA/CLEANED DATA/gdp_clean_data.csv", row.names=FALSE)
#plot gdp growth rate
fig <- plot_ly(gdp, x = ~Date, y = ~value, type = 'scatter', mode = 'lines',line = list(color = 'rgb(240, 128, 128)'))
fig <- fig %>% layout(title = "U.S GPD Growth Rate: 2010 - 2022",xaxis = list(title = "Time"),yaxis = list(title ="GDP Growth Rate"))
figCode
#import the data
inflation_rate <- read.csv("DATA/RAW DATA/inflation-rate.csv")
#cleaning the data
#remove unwanted columns
inflation_rate_clean <- subset(inflation_rate, select = -c(1,HALF1,HALF2))
#convert the data to time series data
inflation_data_ts <- ts(as.vector(t(as.matrix(inflation_rate_clean))), start=c(2010,1), end=c(2023,2), frequency=12)
#export the data
write.csv(inflation_rate_clean, "DATA/CLEANED DATA/inflation_rate_clean_data.csv", row.names=FALSE)
#plot inflation rate
fig <- autoplot(inflation_data_ts, ylab = "Inflation Rate", color="#FFA07A")+ggtitle("U.S Inflation Rate: January 2010 - February 2023")+theme_bw()
ggplotly(fig)Code
#import the data
interest_data <- read.csv("DATA/RAW DATA/interest-rate.csv")
#change date format
interest_data$Date <- as.Date(interest_data$Date , "%m/%d/%Y")
#export the cleaned data
interest_clean_data <- interest_data
write.csv(interest_clean_data, "DATA/CLEANED DATA/interest_rate_clean_data.csv", row.names=FALSE)
#plot interest rate
fig <- plot_ly(interest_data, x = ~Date, y = ~value, type = 'scatter', mode = 'lines',line = list(color='rgb(219, 112, 147)'))
fig <- fig %>% layout(title = "U.S Interest Rate: January 2010 - March 2023",xaxis = list(title = "Time"),yaxis = list(title ="Interest Rate"))
figCode
#import the data
unemployment_rate <- read.csv("DATA/RAW DATA/unemployment-rate.csv")
#change date format
unemployment_rate$Date <- as.Date(unemployment_rate$Date , "%m/%d/%Y")
# export the data
write.csv(unemployment_rate, "DATA/CLEANED DATA/unemployment_rate_clean_data.csv", row.names=FALSE)
#plot unemployment rate
fig <- plot_ly(unemployment_rate, x = ~Date, y = ~Value, type = 'scatter', mode = 'lines',line = list(color = 'rgb(189, 183, 107)'))
fig <- fig %>% layout(title = "U.S Unemployment Rate: January 2010 - March 2023",xaxis = list(title = "Time"),yaxis = list(title ="Unemployment Rate"))
figFrom 2010 to early 2020, SPG’s stock price exhibited a generally upward trend, with occasional dips and plateaus along the way.
In particular, SPG’s stock price experienced a strong rebound following the economic downturn of 2008-2009, reaching pre-recession levels by early 2010. From there, the stock price continued to climb, reaching an all-time high in mid-2016. However, in the years that followed, SPG’s stock price experienced more volatility and fluctuation.
In early 2020, the outbreak of the COVID-19 pandemic led to a sharp decline in SPG’s stock price, as investors became concerned about the impact of the pandemic on the retail industry and consumer spending. However, since mid-2020, SPG’s stock price has shown signs of recovery, likely due to the gradual reopening of retail properties and improving economic conditions.
Overall, SPG’s stock price has been influenced by a range of factors over the years, including economic conditions, consumer spending, competition in the retail industry, and changes in the real estate market.
Since early 2020, Simon Property Group Inc’s stock price has experienced some volatility, likely due to a combination of factors such as global economic uncertainty and fluctuations in consumer demand for the company’s products.
As discussed before, the macroeconomic factors of GDP growth, inflation, interest rates, and unemployment rate are closely interrelated and play a crucial role in the overall health and stability of an economy. From 2010 to 2023, the global economy experienced a mix of ups and downs, with periods of strong GDP growth followed by slowdowns and recessions.
The second plot shows the first difference of the logarithm of the adjusted Simon Property Group Inc stock price. Taking the first difference removes any long-term trends and transforms the time series into a stationary process. From the plot, we can observe that the first difference of the logarithm of the Simon Property Group Inc stock price appears to be stationary, as the mean and variance are roughly constant over time.
Enodogenous and Exogenous Variables
Code
numeric_data <- c("SPG.Adjusted","gdp", "interest", "inflation", "unemployment")
numeric_data <- final[, numeric_data]
normalized_data_numeric <- scale(numeric_data)
normalized_data <- ts(normalized_data_numeric, start = c(2010, 1), end = c(2021,10),frequency = 4)
ts_plot(normalized_data,
title = "Normalized Time Series Data for SPG Stock and Macroeconomic Variables",
Ytitle = "Normalized Values",
Xtitle = "Year")Code
# Get upper triangle of the correlation matrix
get_upper_tri <- function(cormat){
cormat[lower.tri(cormat)]<- NA
return(cormat)
}
cormat <- round(cor(normalized_data_numeric),2)
upper_tri <- get_upper_tri(cormat)
melted_cormat <- melt(upper_tri, na.rm = TRUE)
# Create a ggheatmap
ggheatmap <- ggplot(melted_cormat, aes(Var2, Var1, fill = value))+
geom_tile(color = "white")+
scale_fill_gradient2(low = "blue", high = "red", mid = "white",
midpoint = 0, limit = c(-1,1), space = "Lab",
name="Pearson\nCorrelation") +
theme_minimal()+ # minimal theme
theme(axis.text.x = element_text(angle = 45, vjust = 1,
size = 12, hjust = 1))+
coord_fixed()
ggheatmap +
geom_text(aes(Var2, Var1, label = value), color = "black", size = 4) +
theme(
axis.title.x = element_blank(),
axis.title.y = element_blank(),
panel.grid.major = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
axis.ticks = element_blank(),
legend.justification = c(1, 0),
legend.position = c(0.6, 0.7),
legend.direction = "horizontal")+
guides(fill = guide_colorbar(barwidth = 7, barheight = 1,
title.position = "top", title.hjust = 0.5))Code
par(mfrow=c(1,1))
ccf_result <- ccf(normalized_data[, c("SPG.Adjusted")], normalized_data[, c("gdp")],
lag.max = 300,
main = "Cros-Correlation Plot for SPG Stock Price and GDP Growth Rate ",
ylab = "CCF")Code
cat("The sum of cross correlation function is", sum(abs(ccf_result$acf)))The sum of cross correlation function is 8.137909
Code
par(mfrow=c(1,1))
ccf_result <- ccf(normalized_data[, c("SPG.Adjusted")], normalized_data[, c("interest")],
lag.max = 300,
main = "Cros-Correlation Plot for SPG Stock Price and Interest Rate",
ylab = "CCF")Code
cat("The sum of cross correlation function is", sum(abs(ccf_result$acf)))The sum of cross correlation function is 9.09151
Code
par(mfrow=c(1,1))
ccf_result <- ccf(normalized_data[, c("SPG.Adjusted")], normalized_data[, c("inflation")],
lag.max = 300,
main = "Cros-Correlation Plot for SPG Stock Price and Inflation Rate",
ylab = "CCF")Code
cat("The sum of cross correlation function is", sum(abs(ccf_result$acf)))The sum of cross correlation function is 15.82909
Code
par(mfrow=c(1,1))
ccf_result <- ccf(normalized_data[, c("SPG.Adjusted")], normalized_data[, c("unemployment")],
lag.max = 300,
main = "Cros-Correlation Plot for SPG Stock Priceand Unemployment Rate",
ylab = "CCF")Code
cat("The sum of cross correlation function is", sum(abs(ccf_result$acf)))The sum of cross correlation function is 17.5948
The Normalized Time Series Data for Stock Price and Macroeconomic Variables plot shows the same variables as the first plot but has been normalized to a common range of 0 to 1 using the scale() function in R, which standardizes the variables to have a mean of 0 and a standard deviation of 1. The heatmap analysis of the normalized data reveals that inflation and unemployment rate exhibit strong positive correlations with the stock price indices, indicating that these variables may significantly influence stock price movements. On the other hand, weaker correlations were observed between the stock price indices and GDP and interest rates, suggesting that these variables may have less impact on stock price fluctuations. The cross-correlation feature plots confirm these findings, indicating that inflation and unemployment rate are more suitable feature variables for the ARIMAX model when predicting Simon Property Group Inc movements.
Final Exogenous variables: Macroeconomic indicators: Inflation rate and unemployment rate.
Enodogenous and Exogenous Variables Plot
Code
final_data <- final %>%dplyr::select( Date,SPG.Adjusted, inflation,unemployment)
numeric_data <- c("SPG.Adjusted", "inflation","unemployment")
numeric_data <- final_data[, numeric_data]
normalized_data_numeric <- scale(numeric_data)
normalized_numeric_df <- data.frame(normalized_data_numeric)
normalized_data_ts <- ts(normalized_data_numeric, start = c(2010, 1), frequency = 4)
autoplot(normalized_data_ts, facets=TRUE) +
xlab("Year") + ylab("") +
ggtitle("Simon Property Group Inc Stock Price, Inflation Rate and Unemployment Rate in USA 2010-2023")Code
# Convert your multivariate time series data to a matrix
final_data_ts_multivariate <- as.matrix(normalized_data_ts)
# Check for stationarity using Phillips-Perron test
phillips_perron_test <- ur.pp(final_data_ts_multivariate)
summary(phillips_perron_test)
##################################
# Phillips-Perron Unit Root Test #
##################################
Test regression with intercept
Call:
lm(formula = y ~ y.l1)
Residuals:
Min 1Q Median 3Q Max
-2.4356 -0.1842 -0.0432 0.1307 4.4556
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.006439 0.043712 0.147 0.883
y.l1 0.828205 0.044155 18.757 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.5442 on 153 degrees of freedom
Multiple R-squared: 0.6969, Adjusted R-squared: 0.6949
F-statistic: 351.8 on 1 and 153 DF, p-value: < 2.2e-16
Value of test-statistic, type: Z-alpha is: -27.5627
aux. Z statistics
Z-tau-mu 0.1461
The results of the Phillips-Perron unit root test indicate strong evidence against the null hypothesis of a unit root, as the p-value for the coefficient of the lagged variable is less than the significance level of 0.05. This suggests that the variable y, which is being tested for stationarity, is likely stationary. Furthermore, the test statistic Z-tau-mu is 0.1461, which is smaller than the critical value of Z-alpha (-27.5627), providing further evidence of stationarity.
To determine whether the linear model requires an ARCH model, an ARCH test is conducted. The ACF and PACF plots are also used to identify suitable model values.
Model Fitting
Code
normalized_numeric_df$SPG.Adjusted<-ts(normalized_numeric_df$SPG.Adjusted,star=decimal_date(as.Date("2010-01-01",format = "%Y-%m-%d")),frequency = 4)
normalized_numeric_df$inflation<-ts(normalized_numeric_df$inflation,star=decimal_date(as.Date("2010-01-01",format = "%Y-%m-%d")),frequency = 4)
normalized_numeric_df$unemployment<-ts(normalized_numeric_df$unemployment,star=decimal_date(as.Date("2010-01-01",format = "%Y-%m-%d")),frequency = 4)
fit <- lm(SPG.Adjusted ~ inflation+unemployment, data=normalized_numeric_df)
fit.res<-ts(residuals(fit),star=decimal_date(as.Date("2010-01-01",format = "%Y-%m-%d")),frequency = 4)
############## Then look at the residuals ############
returns <- fit.res %>% diff()
autoplot(returns)+ggtitle("Linear Model Returns")Code
byd.archTest <- ArchTest(fit.res, lags = 1, demean = TRUE)
byd.archTest
ARCH LM-test; Null hypothesis: no ARCH effects
data: fit.res
Chi-squared = 4.086, df = 1, p-value = 0.04324
Code
ggAcf(returns) +ggtitle("ACF for returns")Code
ggPacf(returns) +ggtitle("PACF for returns")The ARCH LM-test was conducted with the null hypothesis of no ARCH effects. The test resulted in a chi-squared value of 4.086 with one degree of freedom, and a very low p-value of 0.04324. This suggests strong evidence against the null hypothesis, indicating the presence of ARCH effects in the data.
Based on the ACF and PACF plots, it appears that there is some significant autocorrelation and partial autocorrelation at multiple lags, which suggests that an ARIMA model may not be sufficient to capture the time series behavior. Additionally, the values for p and q appear to be relatively high, with p = 2 and q = 2 being suggested by the plots.
ARIMAX Model
Code
xreg <- cbind(Inflation = normalized_data_ts[, "inflation"],
Unemployment = normalized_data_ts[, "unemployment"])
fit.auto <- auto.arima(normalized_data_ts[, "SPG.Adjusted"], xreg = xreg)
summary(fit.auto)Series: normalized_data_ts[, "SPG.Adjusted"]
Regression with ARIMA(1,0,0)(1,0,0)[4] errors
Coefficients:
ar1 sar1 Inflation Unemployment
0.9534 -0.3300 0.2778 -0.3783
s.e. 0.0495 0.1831 0.1652 0.0677
sigma^2 = 0.1182: log likelihood = -17.37
AIC=44.75 AICc=46.05 BIC=54.5
Training set error measures:
ME RMSE MAE MPE MAPE MASE
Training set -0.01361406 0.3303232 0.2707079 -56.23445 97.35066 0.343688
ACF1
Training set 0.05506913
Code
checkresiduals(fit.auto)
Ljung-Box test
data: Residuals from Regression with ARIMA(1,0,0)(1,0,0)[4] errors
Q* = 3.0527, df = 6, p-value = 0.8022
Model df: 2. Total lags used: 8
Code
ARIMA.c=function(p1,p2,q1,q2,data){
temp=c()
d=1
i=1
temp= data.frame()
ls=matrix(rep(NA,6*30),nrow=30)
for (p in p1:p2)#
{
for(q in q1:q2)#
{
for(d in 0:1)
{
if(p+d+q<=6)
{
model<- Arima(data,order=c(p,d,q))
ls[i,]= c(p,d,q,model$aic,model$bic,model$aicc)
i=i+1
#print(i)
}
}
}
}
temp= as.data.frame(ls)
names(temp)= c("p","d","q","AIC","BIC","AICc")
temp
}
output <- ARIMA.c(1,2,1,2,data=residuals(fit))
output[which.min(output$AIC),] p d q AIC BIC AICc
1 1 0 1 65.50307 73.30805 66.35414
Code
output[which.min(output$BIC),] p d q AIC BIC AICc
1 1 0 1 65.50307 73.30805 66.35414
Code
output[which.min(output$AICc),] p d q AIC BIC AICc
1 1 0 1 65.50307 73.30805 66.35414
Code
set.seed(1234)
model_output <- capture.output(sarima(fit.res, 1,0,1)) Code
cat(model_output[25:56], model_output[length(model_output)], sep = "\n")$fit
Call:
arima(x = xdata, order = c(p, d, q), seasonal = list(order = c(P, D, Q), period = S),
xreg = xmean, include.mean = FALSE, transform.pars = trans, fixed = fixed,
optim.control = list(trace = trc, REPORT = 1, reltol = tol))
Coefficients:
ar1 ma1 xmean
0.2774 0.4238 -0.0205
s.e. 0.2080 0.1863 0.1133
sigma^2 estimated as 0.1752: log likelihood = -28.75, aic = 65.5
$degrees_of_freedom
[1] 49
$ttable
Estimate SE t.value p.value
ar1 0.2774 0.2080 1.3340 0.1884
ma1 0.4238 0.1863 2.2748 0.0273
xmean -0.0205 0.1133 -0.1813 0.8569
$AIC
[1] 1.259674
$AICc
[1] 1.26929
$BIC
[1] 1.40977
Code
n=length(fit.res)
k= 51
rmse1 <- matrix(NA, (n-k),4)
rmse2 <- matrix(NA, (n-k),4)
rmse3 <- matrix(NA, (n-k),4)
st <- tsp(fit.res)[1]+(k-5)/4
for(i in 1:(n-k))
{
xtrain <- window(fit.res, end=st + i/4)
xtest <- window(fit.res, start=st + (i+1)/4, end=st + (i+4)/4)
#ARIMA(0,1,0) ARIMA(1,1,1)
fit <- Arima(xtrain, order=c(0,1,0),
include.drift=TRUE, method="ML")
fcast <- forecast(fit, h=4)
fit2 <- Arima(xtrain, order=c(1,0,0), seasonal = c(1,0,0),
include.drift=TRUE, method="ML")
fcast2 <- forecast(fit2, h=4)
rmse1[i,1:length(xtest)] <- sqrt((fcast$mean-xtest)^2)
rmse2[i,1:length(xtest)] <- sqrt((fcast2$mean-xtest)^2)
}
plot(1:4,colMeans(rmse1,na.rm=TRUE), type="l",col=2, xlab="horizon", ylab="RMSE")
lines(1:4, colMeans(rmse2,na.rm=TRUE), type="l",col=3)
legend("topleft",legend=c("fit1","fit2"),col=2:4,lty=1)Based on the results of the auto.arima function, the suggested best model is ARIMA(1,0,0)(1,0,0)[4]. However, when we manually test different ARIMA models, we find that ARIMA(0,1,0) has the lowest values for AIC, BIC, and AICC. Additionally, both models have similar standardized residual plots, with means close to 0, indicating a good fit. The ACF plot of residuals also shows no significant lags, further indicating a well-fitted model.
To determine the best model, we conduct cross-validation and compare the RMSE values of both models. The results show that ARIMA(0,1,0) has lower RMSE values than the other model, indicating that it is the better model.
We can then proceed to choose the best GARCH model using ARIMA(0,1,0) as the base model.
Squared Residuals
Code
fit <- lm(SPG.Adjusted ~ inflation+unemployment, data=normalized_numeric_df)
fit.res<-ts(residuals(fit),star=decimal_date(as.Date("2010-01-01",format = "%Y-%m-%d")),frequency = 4)
fit <- Arima(fit.res,order=c(0,1,0))
res=fit$res
plot(res^2,main='Squared Residuals')Code
acf(res^2,24, main = "ACF Residuals Square")Code
pacf(res^2,24, main = "PACF Residuals Square")Code
summary(garchFit(~garch(2,1),res, trace=F))
Title:
GARCH Modelling
Call:
garchFit(formula = ~garch(2, 1), data = res, trace = F)
Mean and Variance Equation:
data ~ garch(2, 1)
<environment: 0x13a5684a8>
[data = res]
Conditional Distribution:
norm
Coefficient(s):
mu omega alpha1 alpha2 beta1
0.04528839 0.00059517 0.14604719 0.38866129 0.66486298
Std. Errors:
based on Hessian
Error Analysis:
Estimate Std. Error t value Pr(>|t|)
mu 0.0452884 0.0388984 1.164 0.244312
omega 0.0005952 0.0190009 0.031 0.975012
alpha1 0.1460472 0.1482030 0.985 0.324401
alpha2 0.3886613 0.2958813 1.314 0.188990
beta1 0.6648630 0.1933162 3.439 0.000583 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Log Likelihood:
-28.51055 normalized: -0.5482799
Description:
Tue Jan 9 21:03:46 2024 by user:
Standardised Residuals Tests:
Statistic p-Value
Jarque-Bera Test R Chi^2 22.15694 1.54412e-05
Shapiro-Wilk Test R W 0.926558 0.003307071
Ljung-Box Test R Q(10) 7.382848 0.6888745
Ljung-Box Test R Q(15) 11.82492 0.6922298
Ljung-Box Test R Q(20) 18.67737 0.5428777
Ljung-Box Test R^2 Q(10) 3.102515 0.9789075
Ljung-Box Test R^2 Q(15) 3.785774 0.9983585
Ljung-Box Test R^2 Q(20) 5.344295 0.9995367
LM Arch Test R TR^2 3.42088 0.9917726
Information Criterion Statistics:
AIC BIC SIC HQIC
1.288867 1.476487 1.272450 1.360796
From the squared residuals of the best ARIMA model, it can be observed that the ACF plot and PACF plot indicate that the residuals are not autocorrelated and are white noise, indicating a good fit of the model. Based on the squared residuals of the best ARIMA model, we can see that the ACF and PACF plots indicate that most of the values lie between the blue lines. Additionally, the p-value is 2 and q-value is 1.
So, the best model is ARIMA(0,1,0) and GARCH(2,1).
Best Model
Code
#fiting an ARIMA model to the Inflation variable
inflation_fit<-auto.arima(normalized_numeric_df$inflation)
finflation<-forecast(inflation_fit)
#fitting an ARIMA model to the Unemployment variable
unemployment_fit<-auto.arima(normalized_numeric_df$unemployment)
funemployment<-forecast(unemployment_fit)
# best model fit for forcasting
xreg <- cbind(Inflation = normalized_data_ts[, "inflation"],
Unemployment = normalized_data_ts[, "unemployment"])
summary(arima.fit<-Arima(normalized_data_ts[, "SPG.Adjusted"],order=c(0,1,0),xreg=xreg),include.drift = TRUE)Series: normalized_data_ts[, "SPG.Adjusted"]
Regression with ARIMA(0,1,0) errors
Coefficients:
Inflation Unemployment
0.4599 -0.4115
s.e. 0.1513 0.0687
sigma^2 = 0.1211: log likelihood = -17.51
AIC=41.03 AICc=41.54 BIC=46.82
Training set error measures:
ME RMSE MAE MPE MAPE MASE
Training set -0.02507978 0.337813 0.2655551 -55.51624 91.68249 0.3371461
ACF1
Training set 0.0474485
Code
summary(final.fit <- garchFit(~garch(2,1), res,trace = F))
Title:
GARCH Modelling
Call:
garchFit(formula = ~garch(2, 1), data = res, trace = F)
Mean and Variance Equation:
data ~ garch(2, 1)
<environment: 0x13916c0a8>
[data = res]
Conditional Distribution:
norm
Coefficient(s):
mu omega alpha1 alpha2 beta1
0.04528839 0.00059517 0.14604719 0.38866129 0.66486298
Std. Errors:
based on Hessian
Error Analysis:
Estimate Std. Error t value Pr(>|t|)
mu 0.0452884 0.0388984 1.164 0.244312
omega 0.0005952 0.0190009 0.031 0.975012
alpha1 0.1460472 0.1482030 0.985 0.324401
alpha2 0.3886613 0.2958813 1.314 0.188990
beta1 0.6648630 0.1933162 3.439 0.000583 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Log Likelihood:
-28.51055 normalized: -0.5482799
Description:
Tue Jan 9 21:03:46 2024 by user:
Standardised Residuals Tests:
Statistic p-Value
Jarque-Bera Test R Chi^2 22.15694 1.54412e-05
Shapiro-Wilk Test R W 0.926558 0.003307071
Ljung-Box Test R Q(10) 7.382848 0.6888745
Ljung-Box Test R Q(15) 11.82492 0.6922298
Ljung-Box Test R Q(20) 18.67737 0.5428777
Ljung-Box Test R^2 Q(10) 3.102515 0.9789075
Ljung-Box Test R^2 Q(15) 3.785774 0.9983585
Ljung-Box Test R^2 Q(20) 5.344295 0.9995367
LM Arch Test R TR^2 3.42088 0.9917726
Information Criterion Statistics:
AIC BIC SIC HQIC
1.288867 1.476487 1.272450 1.360796
Code
ht <- final.fit@h.t #a numeric vector with the conditional variances (h.t = sigma.t^delta)
#############################
data=data.frame(final)
data$Date<-as.Date(data$Date,"%Y-%m-%d")
data2= data.frame(ht,data$Date)
ggplot(data2, aes(y = ht, x = data.Date)) + geom_line(col = '#C39BD3') + ylab('Conditional Variance') + xlab('Date')From the ARIMA(0,1,0), we see that the training set error measures also suggest a good fit, with low mean absolute error, root mean squared error, and autocorrelation of the residuals. GATCH(2,1) model model is used to estimate the volatility of the standardized residuals of the previous regression model. The model includes a mean equation that estimates the mean of the residuals and a variance equation that models the conditional variance of the residuals. The coefficients of the mean equation suggest that the mean of the residuals is close to zero. The variance equation coefficients suggest that the conditional variance of the residuals is dependent on the past conditional variances and the past squared standardized residuals. The model’s AIC, BIC, SIC, and HQIC values are all relatively low, indicating a good fit of the model. The standardized residuals tests indicate that the residuals are approximately normally distributed and that there is no significant autocorrelation in the residuals.
The volatility of the model seems high in 2020 but has decreased gradually in the past few months. This could indicate that the asset’s price was experiencing a lot of fluctuations in 2020, but the market has stabilized recently.
Model Diagnostics
Code
fit2<-garch(res,order=c(2,1),trace=F)
checkresiduals(fit2) Code
qqnorm(fit2$residuals, pch = 1)
qqline(fit2$residuals, col = "blue", lwd = 2)Code
Box.test (fit2$residuals, type = "Ljung")
Box-Ljung test
data: fit2$residuals
X-squared = 0.41569, df = 1, p-value = 0.5191
The ACF plot of the residuals shows all the values between the blue lines, which indicates that the residuals are not significantly autocorrelated. The range of values for the residual plot between -2 and 4 is considered acceptable. Additionally, the QQ plot of the residuals shows a linear plot on the line, which is another good indication that the residuals are normally distributed. The QQ plot is a valuable tool to assess if the residuals follow a normal distribution, and in this case, the plot suggests that the residuals do indeed follow a normal distribution.
The Box-Ljung test, a p-value of 0.5186 indicates that the model’s residuals are not significantly autocorrelated, meaning that the model has captured most of the information in the data. This result is good because it suggests that the model is a good fit for the data and has accounted for most of the underlying patterns in the data. Therefore, we can rely on the model’s predictions and use them to make informed decisions.
Forecast
Code
predict(final.fit, n.ahead = 5, plot=TRUE) meanForecast meanError standardDeviation lowerInterval upperInterval
1 0.04528839 1.1060591 1.1060591 -2.122548 2.213124
2 0.04528839 0.9964814 0.9964814 -1.907779 1.998356
3 0.04528839 1.1319382 1.1319382 -2.173270 2.263847
4 0.04528839 1.1939566 1.1939566 -2.294824 2.385400
5 0.04528839 1.2862968 1.2862968 -2.475807 2.566384
The forecasted plot is based on the best model ARIMAX(0,1,0)+GARCH(2,1). This model takes into account the autoregressive and moving average components of the data, as well as the impact of exogenous variables on the time series. Additionally, the GARCH component of the model accounts for the volatility clustering in the data. Overall, this model is well-suited to make accurate predictions about future values of the time series.
Equation of the Model
The equation of the ARIMAX(0,1,0) model is:
\(Y(t) = Y(t-1) + \epsilon(t)\)
where \(Y(t)\) is the time series variable and \(\epsilon(t)\) is the error term. The equation of the GARCH(2,1) model is:
\(\sigma_t^2 = \omega + \alpha_1\varepsilon^2_(t-1) + \alpha_2\varepsilon^2_(t-2) + \beta_1\sigma^2(t-1)\)
where \(\sigma_t^2\) represents the conditional variance of the time series at time \(t\), \(\varepsilon_t\) represents the error term or innovation at time \(t\), \(\omega\) is a constant representing the long-run average variance, and \(\alpha_1\), \(\alpha_2\), and \(\beta_1\) are the coefficients to be estimated.
The combined equation of the ARIMAX(1,1,1)+GARCH(1,1) model is:
\(Y(t) = Y(t-1) + \epsilon(t)\)
\(\epsilon(t) = \sigma(t) * \epsilon~(t)\)
\(\sigma_t^2 = \omega + \alpha_1\varepsilon^2_(t-1) + \alpha_2\varepsilon^2_(t-2) + \beta_1\sigma^2(t-1)\)